home *** CD-ROM | disk | FTP | other *** search
/ Champak 114 / Vol 114.iso / games / way_of_t.swf / scripts / frame_4 / DoAction.as
Encoding:
Text File  |  2010-08-12  |  1.2 KB  |  50 lines

  1. function CollisionDetection(striking, struck)
  2. {
  3.    if(_root[striking].onFloor == _root[struck].onFloor)
  4.    {
  5.       if(_root[striking].direction == "left")
  6.       {
  7.          distance = _root[striking + "Bounds"].xMin - _root[struck + "Bounds"].xMax;
  8.       }
  9.       else
  10.       {
  11.          distance = _root[struck + "Bounds"].xMin - _root[striking + "Bounds"].xMax;
  12.       }
  13.       if(_root[striking].direction == _root[struck].direction)
  14.       {
  15.          outerreach = _root[striking].outerreach + 5;
  16.          innerreach = _root[striking].innerreach + 5;
  17.       }
  18.       else
  19.       {
  20.          outerreach = _root[striking].outerreach;
  21.          innerreach = _root[striking].innerreach;
  22.       }
  23.       if(innerreach < distance && distance < outerreach)
  24.       {
  25.          contact = 1;
  26.       }
  27.       else
  28.       {
  29.          contact = 0;
  30.       }
  31.       if(_root[striking].direction == _root[struck].direction && contact)
  32.       {
  33.          if(_root[struck].direction == "left")
  34.          {
  35.             _root[struck].direction = "right";
  36.          }
  37.          else
  38.          {
  39.             _root[struck].direction = "left";
  40.          }
  41.       }
  42.    }
  43.    else
  44.    {
  45.       contact = 0;
  46.    }
  47.    return contact;
  48. }
  49. stop();
  50.